package org.opsli.modulars.system.appValve.service.impl;

import org.opsli.api.wrapper.system.user.UserModel;
import org.opsli.common.api.Result;
import org.opsli.core.base.service.impl.CrudServiceImpl;
import org.opsli.modulars.system.appValve.service.AppValveInterface;
import org.opsli.modulars.system.user.entity.SysUser;
import org.opsli.modulars.system.user.mapper.UserMapper;
import org.springframework.stereotype.Service;

@Service
public class AppValveInterfaceImpl extends CrudServiceImpl<UserMapper, SysUser, UserModel> implements AppValveInterface {
    @Override
    public UserModel queryByUserName(String username) {
        return null;
    }

    @Override
    public Result<?> checkUserIsEffective(UserModel userModel) {
        Result<?> result = new Result<Object>();
        //情况1：根据用户信息查询，该用户不存在
        if (userModel == null) {
            result.error500("该用户不存在，请注册");
            //baseCommonService.addLog("用户登录失败，用户不存在！", CommonConstant.LOG_TYPE_1, null);
            return result;
        }
        //情况2：根据用户信息查询，该用户已停用
        if ("0".equals(userModel.getEnable())) {
            //baseCommonService.addLog("用户登录失败，用户名:" + userModel.getUsername() + "已停用！", CommonConstant.LOG_TYPE_1, null);
            result.error500("该用户已停用");
            return result;
        }
        //情况3：根据用户信息查询，该用户已冻结
//        if (CommonConstant.USER_FREEZE.equals(userModel.getStatus())) {
//            baseCommonService.addLog("用户登录失败，用户名:" + userModel.getUsername() + "已冻结！", CommonConstant.LOG_TYPE_1, null);
//            result.error500("该用户已冻结");
//            return result;
//        }
        return result;
    }
}
